home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
114_01
/
config3.bds
< prev
next >
Wrap
Text File
|
1987-07-13
|
2KB
|
99 lines
/* Screen editor configurator: general utilities
*
* Source: config3.bds
* Version: December 20, 1981.
*/
#include bdscio.h
#include config.h
/* return: is first token in args a number ? */
/* return value of number in *val */
number(args,val) char *args; int *val;
{
char c;
c=*args++;
if (c<'0' || c>'9') {
return(NO);
}
*val=c-'0';
while (c=*args++) {
if (c<'0' || c>'9') {
break;
}
*val=(*val*10)+c-'0';
}
return(YES);
}
/* convert character buffer to numeric */
ctoi(buf,index) char *buf; int index;
{
int k;
while ( (buf[index]==' ') +
(buf[index]==TAB) ) {
index++;
}
k=0;
while (buf[index]>='0' && buf[index]<='9') {
k=(k*10)+buf[index]-'0';
index++;
}
return(k);
}
/* put decimal integer n in field width >= w */
putdec(n,w) int n,w;
{
char chars[10];
int i,nd;
nd=itoc(n,chars,10);
i=nd;
while (i++<w) {
putchar(' ');
}
i=0;
while (i<nd) {
putchar(chars[i++]);
}
}
/* convert integer n to character string in str */
itoc(n,str,size) int n; char *str; int size;
{
int absval;
int len;
int i,j,k;
absval=abs(n);
/* generate digits */
str[0]=0;
i=1;
while (i<size) {
str[i++]=(absval%10)+'0';
absval=absval/10;
if (absval==0) {
break;
}
}
/* generate sign */
if (i<size && n<0) {
str[i++]='-';
}
len=i-1;
/* reverse sign, digits */
i--;
j=0;
while (j<i) {
k=str[i];
str[i]=str[j];
str[j]=k;
i--;
j++;
}
return(len);
}
acte